package com.shujia.day06.homework.code03.info;

public class GoodInfo {
    /*
        属性：商品编号，商品名称，所属类别，商品数量（大于 0)，商品价格（大于 0)，
        方法：盘点的方法，描述商品信息。内容包括商品名称，商品数量，商品价格，  现在商品总价以及所属类别信息
     */

    private String goodId;
    private String goodName;

    private GoodType type;

    private int goodNum;

    private double goodPrice;

    public GoodInfo(String goodId, String goodName, GoodType type, int goodNum, double goodPrice) {
        this.goodId = goodId;
        this.goodName = goodName;
        this.type = type;
        setGoodNum(goodNum);
        setGoodPrice(goodPrice);
    }

    public void show(){
        System.out.println("商品名称："+goodName);
        System.out.println("所属类别："+type.getTypeName());
        System.out.println("商品售价："+goodPrice);
        System.out.println("库存总量："+goodNum);
        System.out.println("商品总价："+goodNum * goodPrice);
    }


    public String getGoodId() {
        return goodId;
    }

    public void setGoodId(String goodId) {
        this.goodId = goodId;
    }

    public String getGoodName() {
        return goodName;
    }

    public void setGoodName(String goodName) {
        this.goodName = goodName;
    }

    public GoodType getType() {
        return type;
    }

    public void setType(GoodType type) {
        this.type = type;
    }

    public int getGoodNum() {
        return goodNum;
    }

    public void setGoodNum(int goodNum) {
        if(goodNum >=0){
            this.goodNum = goodNum;
        }else {
            System.out.println("数量不能小于0");
            this.goodNum = 0;
        }

    }

    public double getGoodPrice() {
        return goodPrice;
    }

    public void setGoodPrice(double goodPrice) {

        if(goodPrice >=0){
            this.goodPrice = goodPrice;
        }else {
            System.out.println("价格不能小于0");
            this.goodPrice = 0.0;
        }
    }
}
